using System;
using Sedna.Core.Controller.Configurations.Enums;

namespace Sedna.Core.Controller.Configurations
{
	public class FrameConfiguration: ClientScriptingConfiguration, IFrameConfiguration
	{
		private string stateBindPath;
		private string stateUnbindPath;
		private string onStateBindPath;
		private string onStateUnbindPath;
		private string offStateBindPath;
		private string offStateUnbindPath;

        private bool resetStateOnPostBack;

        private bool isStatic = false;
        private FrameState offState = FrameState.Collapsed;
        private FrameState state = FrameState.Collapsed;
        private string url;
        private bool collapseOthers = true;

        #region Properties

	    public bool ResetStateOnPostBack
	    {
	        get { return resetStateOnPostBack; }
	        set { resetStateOnPostBack = value; }
	    }

	    public FrameState State
	    {
	        get { return state; }
	        set { state = value; }
	    }

	    public string Url
	    {
	        get { return url; }
	        set { url = value; }
	    }

	    public bool CollapseOthers
	    {
	        get { return collapseOthers; }
	        set { collapseOthers = value; }
	    }

	    public bool IsStatic
	    {
	        get { return isStatic; }
	        set
	        {
	            isStatic = value;
                ClientScriptingEnabled = !IsStatic;
	        }
	    }
	    
	    public FrameState OffState
	    {
	        get { return offState; }
	        set { offState = value; }
	    }

	    public string StateBindPath
		{
			get { return stateBindPath; }
			set { stateBindPath = value; }
		}

		public string StateUnbindPath
		{
			get { return stateUnbindPath; }
			set { stateUnbindPath = value; }
		}

		public string StatePath
		{
			set
			{
				stateUnbindPath = value;
				stateBindPath = value;
			}
		}


		public string OnStateBindPath
		{
			get { return onStateBindPath; }
			set { onStateBindPath = value; }
		}

		public string OnStateUnbindPath
		{
			get { return onStateUnbindPath; }
			set { onStateUnbindPath = value; }
		}

		public string OnStatePath
		{
			set
			{
				onStateUnbindPath = value;
				onStateBindPath = value;
			}
		}

		public string OffStateBindPath
		{
			get { return offStateBindPath; }
			set { offStateBindPath = value; }
		}

		public string OffStateUnbindPath
		{
			get { return offStateUnbindPath; }
			set { offStateUnbindPath = value; }
		}

		public string OffStatePath
		{
			set
			{
				offStateUnbindPath = value;
				offStateBindPath = value;
			}
        }

        #endregion

        public override IConfiguration CreateFromTemplate()
	    {
	        FrameConfiguration that = (FrameConfiguration) base.CreateFromTemplate();
		    that.stateBindPath=stateBindPath;
            that.stateUnbindPath = stateUnbindPath;
            that.onStateBindPath = onStateBindPath;
            that.onStateUnbindPath = onStateUnbindPath;
            that.offStateBindPath = offStateBindPath;
            that.offStateUnbindPath = offStateUnbindPath;
            that.isStatic = isStatic;
            that.offState = offState;
            that.state = state;
            that.url = url;
            that.collapseOthers = collapseOthers;
            return that;
	    }
	}
}
